package com.hanggold.endpoint.config;

import com.hanggold.endpoint.filter.EndpointFilter;
import com.hanggold.endpoint.filter.EndpointServlet;
import com.hanggold.endpoint.filter.EndpointServletRegistarationBean;
import com.hanggold.endpoint.filter.FilterBeanRegister;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2019-07-25 15:46
 * @since 1.0.0
 **/

@Configuration
public class FilterConfig {

    @Bean(name = "endpointFilter")
    public EndpointFilter endpointFilter() {
        return new EndpointFilter();
    }

    @Bean
    public FilterBeanRegister filterBeanRegister(@Qualifier("endpointFilter") EndpointFilter filter) {
        return new FilterBeanRegister(filter);
    }

    @Bean
    public EndpointServlet endpointServlet() {
        EndpointServlet endpointServlet = new EndpointServlet();
        return endpointServlet;
    }

    @Bean
    public EndpointServletRegistarationBean endpointServletRegistarationBean(EndpointServlet endpointServlet) {
        EndpointServletRegistarationBean endpointServletRegistarationBean =
                new EndpointServletRegistarationBean(endpointServlet);
        return endpointServletRegistarationBean;
    }


}
